package com.renting.modules.sys.web;

import com.renting.common.entity.ResultList;
import com.renting.modules.sys.dao.RoleDao;
import com.renting.modules.sys.entity.Menu;
import com.renting.modules.sys.entity.Role;
import com.renting.modules.sys.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin("*")
public class RoleController {

    @Autowired
    RoleDao roleDao;
    @Autowired
    RoleService roleService;


    @RequestMapping(value = "v1/sys/roles", method = RequestMethod.GET)
    public String getRoles() {
        ResultList<Role> roleResultList = new ResultList<>();
        int total = (int) roleDao.count();
        roleResultList.setTotal(total);
        roleResultList.setData(roleService.getRoles());
        return roleResultList.toJSONString();
    }
}
